***** RUN DO_MASTER.do ***** do "$Do\DO_MASTER.do"

global program "OA_TableB33"
cap log close
cap log using "$Log\log_$program$today", replace

**** REPLICATION OF TABLE B.3.3****

clear all
set mem 2g
set more off

// Import data

use $Data\data_news_voting, clear

// Get baseline controls

global ctrl_base		"sh_lde lpop_A sh_F sh_F_new sh_cspsup sh_sec sh_ter lmean_reink lmean_reink2 charact_altitude charact_altitude_std sh_active sh_young sh_prot sh_M com_property mk"
global ctrl_plus		"mean_votation lcrSR_F_N"

global fe				"charact_agglo"
global fe_iv			"I_charact_agglo_*"
global cluster			"charact_agglo"

// Column 1

reghdfe oui $endog_std /// 
	$ctrl_plus /// 
	$ctrl_base ///	
	if sample_hq00dstr==1, ///
	absorb($fe) cluster($cluster) keepsing	
estimates store OLS_tabloid1

// Column 2

reghdfe oui $ctrl_plus $ctrl_base (endog_11m_t_std endog_11m_not_std = instr_dev11m_t_std instrA_dev11m_not_std) ///
	if sample_hq00dstr==1, ///
	cluster($cluster) absorb($fe) old keepsing	
estimates store TSLS_tabloid1

// Column 3

reghdfe oui endog_F_mk endog_N_mk /// 
	$ctrl_plus /// 
	$ctrl_base ///	
	if sample_hq00dstr==1, ///
	absorb($fe) cluster($cluster) keepsing	
estimates store OLS_F_N

// Column 4

reghdfe oui $ctrl_plus $ctrl_base (endog_F_mk endog_N_mk = instr_dev_A_mk instr_dev_mk) ///
	if sample_hq00dstr==1, ///
	cluster($cluster) absorb($fe) old keepsing	
estimates store TSLS_F_N

// Labels

la var endog_mk		 		"Crime News Exposure ($ \mathtt{CNE} $)"
la var endog_11m_t_std 		"[0.1em] Crime News Exposure : Tabloids"
la var endog_11m_not_std	"[0.1em] Crime News Exposure : High-quality"
la var endog_N_mk	 		"[0.1em] Crime News Exposure : Swiss crimes"
la var endog_F_mk	 		"[0.1em] Crime News Exposure : Foreign crimes"
la var lcrSR_F_N 			"[0.1em] Local $ \mathtt{CPD} $"
la var mean_votation 		"[0.1em] Past Vote Outcomes"

// For paper

estout OLS_tabloid1 TSLS_tabloid1 OLS_F_N TSLS_F_N ///
	using "$Results\\$program.tex", replace style(tex) type label	///
	cells(b(star fmt(%9.3f)) se(par fmt(%9.3f)))  ///
	stats(N r2_a rkf, lab("Observations" "Adjusted $ R^2 $" "First-stage F-statistic") fmt(0 3 2)) /// 
	collabels(none) ///
	mlabels(, span none prefix(\multicolumn{@span}{c}{) suffix(})) ///
	msign(--) starlevels($^c$ .1 $^b$ .05 $^a$ .01) ///
	keep(endog_11m_t_std endog_11m_not_std endog_F_mk endog_N_mk mean_votation lcrSR_F_N) /// 
	order(endog_11m_t_std endog_11m_not_std endog_N_mk endog_F_mk lcrSR_F_N mean_votation) ///
	title(News and voting: Tabloids and high-quality newspapers) ///	
	prehead("\begin{table}[!h]" ///
	"\centering" ///
	"%\resizebox {0.8\textwidth}{!}{%" ///
	"\begin{threeparttable}" ///
	"\begin{footnotesize}" ///
	"\caption{\small{@title}\label{$program}}" ///
	"\begin{tabular*}{\columnwidth}{@{\extracolsep{\stretch{1}}}l*{@M}{c}@{}}" ///
	"\hline" "\hline" ///	
	"\\" ///
	"Dependent Variable 		&\multicolumn{4}{c}{Minaret Ban approval (\%Yes)}	\\" ///
	"						  	\cmidrule(lr){2-5}" ///
	"Specification				&\multicolumn{2}{c}{Tabloids vs Non-Tabloids} &\multicolumn{2}{c}{Swiss vs Foreign News} \\" ///							
	"						  	\cmidrule(lr){2-3} \cmidrule(lr){4-5} " ///
	"							&\multicolumn{1}{c}{OLS} 	&\multicolumn{1}{c}{2SLS} &\multicolumn{1}{c}{OLS} &\multicolumn{1}{c}{2SLS}  \\" ///
	"						  	\cmidrule(lr){2-2} \cmidrule(lr){3-3} \cmidrule(lr){4-4} \cmidrule(lr){5-5}" ///
	"							&\multicolumn{1}{c}{(1)} 	&\multicolumn{1}{c}{(2)} &\multicolumn{1}{c}{(3)} &\multicolumn{1}{c}{(4)}  \\") ///
	posthead("\hline" ///
	"\\") ///
	prefoot("\\" ///
	"\hline") ///
	postfoot("\hline" "\hline" ///
	"\end{tabular*}" /// 
	"\end{footnotesize}" ///
	"\begin{tablenotes}[normal,flushleft]" ///
	"\begin{scriptsize}" ///
	"\item \emph{Notes}:" /// 
	"The unit of observation is a municipality. " /// 
	"Standard errors clustered at agglomeration level in parentheses. " /// 
	"{$^c$} significant at 10\%; {$^b$} significant at 5\%; {$^a$} significant at 1\%. " /// 
	"Columns (1) and (3) show OLS estimates. Columns (2) to (4) present the second-stage estimates of 2SLS regressions." /// 
	"Columns (1) and (2) present estimates where $ \mathtt{CPD} $ is computed for tabloids and non-tabloids separately." /// 	
	"Columns (3) and (4) show estimates where news-based $ \mathtt{CPD} $ is computed for Native and Foreigners separately." ///
	"The tabloid versus non-tabloid classification comes from Medienqualitatsrating Schweiz (see www.mqr-schweiz.ch)." ///
	"Newspapers classified as tabloid in our sample are \textit{20 Minuten}, \textit{20 Minutes}, and \textit{Le Matin}." ///
	"The other newspapers in our sample are classified as non-tabloid". ///
	"All regressions include the full vector of controls of Table \ref{Main_Table2}. " ///
	"" ///
	"\end{scriptsize}" ///
	"\end{tablenotes}" ///
	"\end{threeparttable}%}" ///
	"\end{table}")

cap log close
